import os
# os.environ['USE_PATH_FOR_GDAL_PYTHON'] = 'YES'
os.environ["PATH"] = "D:\\develop\\Anaconda3\\envs\\geo_env\\Lib\\site-packages\\osgeo;"+os.environ["PATH"]
os.environ["PYTHONPATH"] = "D:\\develop\\Anaconda3\\envs\\geo_env\\Lib\\site-packages\\osgeo;"+os.environ["PATH"]

from osgeo import gdal
from osgeo import osr
import sys

# strss = os.path.dirname(sys.argv[0]) + '/proj'
# os.environ['PROJ_LIB'] = strss

# 获取需要计算的DEM信息
def getDemTifInfo(path):
    inraster = gdal.Open(path)  # 读取路径中的栅格数据
    # prj = osr.SpatialReference()
    # prj.ImportFromWkt(inraster.GetProjection())
    prj = inraster.GetProjection() # str类型的proj
    A_geotrans = inraster.GetGeoTransform()
    return {
        'data': inraster,
        'prj': prj,
        'geotrans': A_geotrans,
        'X': (inraster.RasterXSize) * A_geotrans[1],
        'Y': (inraster.RasterYSize) * A_geotrans[5]
    }
getDemTifInfo('G:\\code\\ydh\\py_tiff_back\\testData\\tiffData\\RS_FOR_BJ_FMP_202409030610_202409031110_1H_5_1_1.tif')